<template>
  <view class="scrollbox">
    <u-navbar title="每日广告情况"> </u-navbar>
    <getdatascrollview ref="getdatascrollview" :api="api" :seardata="tablequery">
      <template #default="{ list }">
        <view class="searchcontent">
          <selectzitem v-model="searchdata.appletId" :options="appletIdOption" @change="change" style="flex: 1;"
            :btnfalg="true">
          </selectzitem>
          <!-- <deptSelect v-model="searchdata.deptId" @change="change"></deptSelect> -->
        </view>
        <view class="znum">
          共计收入:<text class="text">¥{{ znum }}</text>
        </view>
        <item v-for="item in list" :item="item"> </item>
      </template>
    </getdatascrollview>
  </view>
</template>

<script>
import { slotoneDay } from "@/api/appletManage/advertising";
import { getEnum } from "@/api/appletManage/advertising";
import item from "./components/item.vue";
export default {
  components: { item },
  data() {
    return {
      appletIdOption: [],
      customstyle: {
        margin: 0,
        flex: 0,
      },
      znum: 0,
      tablequery: {},

      searchdata: {},
      searchinputs: [],
    };
  },
  mounted() {
    this.init();
  },
  onShow() {
    this.$refs.getdatascrollview && this.$refs.getdatascrollview.onRefresh();
  },
  methods: {
    async api(reqdata) {
      let data = await slotoneDay(reqdata);
      this.znum = data.data.sumIncome;
      return {
        data: data.data.ipage,
      };
    },
    async init() {
      let appletdata = await getEnum("applet");
      appletdata = appletdata.data;
      let appletoption = [];
      Object.keys(appletdata).forEach((e) => {
        appletoption.push({
          label: appletdata[e],
          value: e,
        });
      });
      this.appletIdOption = appletoption;
      console.log(appletoption, 1234);
    },
    change() {
      this.onsearch();
    },
    sxfn() {
      this.$refs.sxpopup.open(this.searchinputs).then((data) => {
        this.searchdata = {
          ...this.searchdata,
          ...data,
        };
        this.onsearch();
      });
    },
    async onsearch() {
      this.tablequery = {
        ...this.searchdata,
      };

      this.$nextTick(() => {
        this.$refs.getdatascrollview.onRefresh();
      });
    },
  },
};
</script>
<style>
page {
  background: #fff;
}
</style>
<style lang="scss" scoped>
.edtbtn {
  color: #1890ff;
  font-size: 28rpx;
}

.znum {
  padding: 20rpx;
  font-size: 28rpx;

  .text {
    color: #32ae57;
    font-weight: bold;
  }
}

.searchcontent {
  display: flex;
  align-items: center;
  padding: 20rpx 20rpx 0 20rpx;

  .sx {
    padding-left: 20rpx;
    display: flex;
    font-size: 28rpx;
  }
}
</style>
